//ybzuo
//2010.03
//UI Compote base Imp
#pragma once
#include "i_UIcompote.h"
#include <list>
#include <map>
class imp_UIcompte :public i_UIcompote
{
	public:
		//position
		void set_position(float _x,float _y)
		{
			if(_x>=0.0f&&_x<=1.0f) m_x=_x;
			if (_y>=0.0f&&_y<=1.0f) m_y=_y;	
		}
		void set_x(float _x){if(_x>=0.0f&&_x<=1.0f) m_x=_x;}
		void set_y(float _y){if (_y>=0.0f&&_y<=1.0f) m_y=_y;}
		float get_x()const	{return m_x;}
		float get_y()const{return m_y;}
		//z-buffers
		void set_zbuffer(float _z){if(_z>=0.0f)m_z=_z;}
		float get_zbuffer()const{return m_z;}
		//size
		void set_width(float _w){if(_w>=0.0f&&_w<=1.0f)m_width=_w;}
		void set_height(float _h){if(_h>=0.0f&&_h<=1.0f)m_height=_h;}
		void set_size(float _w,float _h)
		{	
			if(_w>=0.0f&&_w<=1.0f)m_width=_w;
			if(_h>=0.0f&&_h<=1.0f)m_height=_h;
		}
		float get_width()const{return m_width;}
		float get_height()const{return m_height;}
		void scale(float _widthS,float _heightS)
		{
			if(_widthS>=0.0f) m_x_scale=_widthS;
			if(_heightS>=0.0f) m_y_scale=_heightS;
		}
		float get_scale_x()const{return m_x_scale;}
		float get_scale_y()const{return m_y_scale;}
		//add element;
		 bool add_element(std::string _name,i_UIelement* _element);
		//remove element
		 bool remove_element(std::string _name);
		//add logic
		 bool add_logic(i_UIlogic* _logic);
		//render
		 void render(){}
		//update 
		 void update(){}
		//if active
		 bool active(){return m_active;}
        //
		 void  enable_active(bool b){m_active=b;}

		 void set_windos_size(int _w,int _h);

		 void on_message(ILTMessage_Read* _msg);

		//construct/decon
		imp_UIcompte();
		~imp_UIcompte();


	protected:
		typedef std::map<std::string,i_UIelement*> ElementColl;
		typedef std::map<std::string,i_UIelement*>::iterator ElementCollIt;
		typedef std::list<i_UIlogic*> LogicColl;
		typedef std::list<i_UIlogic*>::iterator LogicCollIt;

		ElementColl& get_element_coll(){return m_elements;}
		LogicColl& get_logic_coll(){return m_logics;}
	private:
		//position
		float m_x;
		float m_y;
		//z-buffer
		float m_z;
		//size
		float m_width;
		float m_height;
		//angle
		float m_angle;
		//scale
		float m_x_scale;
		float m_y_scale;

		int m_window_w;
		int m_window_h;
		bool m_active;
		//effect list
		LogicColl m_logics;
		//uiElement map
		ElementColl m_elements;
		ElementCollIt m_element_it;


		

};